/*
 * @Description: 描述信息
 * @Version: 版本号
 * @Author: xuebao
 * @Date: 2023-12-10 18:45:55
 * @LastEditors: xuebao
 * @LastEditTime: 2023-12-11 18:03:05
 */
/**
 * localStorage的封装
 */

//设置
export const setItem = (key: string, value: any) => {
  localStorage.setItem(key, JSON.stringify(value));
}

//获取
export const getItem = (key: any) => {
  const value = localStorage.getItem(key);
  if (!value) return ''

  try {
    return JSON.parse(value)
  } catch (error) {
    return value
  }
}

//删除
export const removeItem = (key: string) => {
  localStorage.removeItem(key);
}

//清楚
export const clear = () => {
  localStorage.clear()
}
